package com.sun.lib.util;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;

import androidx.annotation.NonNull;

import com.alibaba.android.arouter.facade.Postcard;
import com.alibaba.android.arouter.launcher.ARouter;

/*
 * Created by Administrator on 2019/7/30.
 *
 * #                                                   #
 * #                       _oo0oo_                     #
 * #                      o8888888o                    #
 * #                      88" . "88                    #
 * #                      (| -_- |)                    #
 * #                      0\  =  /0                    #
 * #                    ___/`---'\___                  #
 * #                  .' \\|     |# '.                 #
 * #                 / \\|||  :  |||# \                #
 * #                / _||||| -:- |||||- \              #
 * #               |   | \\\  -  #/ |   |              #
 * #               | \_|  ''\---/''  |_/ |             #
 * #               \  .-\__  '-'  ___/-. /             #
 * #             ___'. .'  /--.--\  `. .'___           #
 * #          ."" '<  `.___\_<|>_/___.' >' "".         #
 * #         | | :  `- \`.;`\ _ /`;.`/ - ` : | |       #
 * #         \  \ `_.   \_ __\ /__ _/   .-` /  /       #
 * #     =====`-.____`.___ \_____/___.-`___.-'=====    #
 * #                       `=---='                     #
 * #     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~   #
 * #                                                   #
 * #               佛祖保佑         永无BUG              #
 * #                                                   #
 */
public class IntentUtil {
    public static void startActivity(@NonNull Context context, @NonNull String path, Bundle bundle) {
        Postcard postcard = ARouter.getInstance().build(path);
        if (bundle != null)
            postcard.with(bundle);
        postcard.navigation(context);
    }

    public static void startActivity(@NonNull Context context, @NonNull String path) {
        startActivity(context, path, null);
    }

    public static void startActivityResult(@NonNull Activity context, @NonNull String path, Bundle bundle, int requestCode) {
        Postcard postcard = ARouter.getInstance().build(path);
        if (bundle != null)
            postcard.with(bundle);
        postcard.navigation(context, requestCode);
    }

    public static void startActivityResult(@NonNull Activity activity, @NonNull String path, int requestCode) {
        startActivityResult(activity, path, null, requestCode);
    }

}
